package com.example.lasttrain.common;

import java.util.Calendar;
import java.util.Date;

import android.app.AlarmManager;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;



public class TimeData {
	public static int INVALID_TIME = -1;
	private int hour;
	private int minute;
	
    private Calendar calendar;
    private Calendar calendar2;
    private int cal_hour;
    private int cal_minute;
	
	public TimeData(int hour, int minute) {
		if(hour >= 0 && hour <= 24)
			this.hour = hour;
		else
			this.hour = INVALID_TIME;
		
		if(minute >= 0 && minute < 60)
			this.minute = minute;
		else
			this.minute = INVALID_TIME;
	}
	
	public TimeData(String timeSequence){
		int tempHour, tempMinute, colonIndex;
		
		colonIndex = timeSequence.indexOf(':');
		tempHour = Integer.parseInt(timeSequence.substring(0, colonIndex-1));
		tempMinute = Integer.parseInt(timeSequence.substring(colonIndex+1));
		
		if(tempHour >= 0 && tempHour <= 24)
			this.hour = tempHour;
		else
			this.hour = INVALID_TIME;
		
		if(tempMinute >= 0 && tempMinute < 60)
			this.minute = tempMinute;
		else
			this.minute = INVALID_TIME;
	}
	
	public int getHour(){
		return hour;
	}
	
	public int getMinute(){
		return minute;
	}
	
	public boolean isAvailableTime(){
		if(hour == INVALID_TIME || minute == INVALID_TIME)
			return false;
		else
			return true;
	}
	
}
